"""
Consume message from Queue abc Vhost test.
"""
import time
import pika

credentials = pika.PlainCredentials(username="test", password="123456")
connection = pika.BlockingConnection(pika.ConnectionParameters(host='', virtual_host='test',
                                                               credentials=credentials))
channel = connection.channel()

for method_frame, properties, body in channel.consume('abc'):
    print(method_frame, properties, body.decode())
    channel.basic_ack(method_frame.delivery_tag)
    time.sleep(1)

# Cancel the consumer and return any pending messages
requeued_messages = channel.cancel()
print('Requeued %i messages' % requeued_messages)
connection.close()
